<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>01-属性</title>
    <script>
        window.onload = function () {
            let sub = document.getElementById("sub");
            let children = document.frm.children;
            sub.onclick = function () {
                for (let i = 0; i < children.length; i++) {
                    let child = children[i];
                    if(child.checked){
                        alert(child.value == 1 ? "男":"女");
                    }
                }
                event.preventDefault();
            }
        }
    </script>
</head>
<body>
  <form action="#" name="frm">
        男: <input type="radio" name="sex" value="1" checked>
        女: <input type="radio" name="sex" value="0">
        <input type="submit" id="sub">
  </form>
</body>
</html>